|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectThinkGear
public class ThinkGear
| Field Summary | |
|---|---|
static int |
BAUD_115200
|
static int |
BAUD_1200
Baud rate for use with Connect() and SetBaudrate(). |
static int |
BAUD_2400
|
static int |
BAUD_4800
|
static int |
BAUD_57600
|
static int |
BAUD_9600
|
static int |
DATA_ALPHA1
|
static int |
DATA_ALPHA2
|
static int |
DATA_ATTENTION
|
static int |
DATA_BATTERY
Data type that can be requested from GetValue(). |
static int |
DATA_BETA1
|
static int |
DATA_BETA2
|
static int |
DATA_DELTA
|
static int |
DATA_GAMMA1
|
static int |
DATA_GAMMA2
|
static int |
DATA_MEDITATION
|
static int |
DATA_POOR_SIGNAL
|
static int |
DATA_RAW
|
static int |
DATA_THETA
|
static int |
MAX_CONNECTION_HANDLES
Maximum number of Connections that can be requested before being required to free one. |
static int |
STREAM_5VRAW
|
static int |
STREAM_FILE_PACKETS
|
static int |
STREAM_PACKETS
Data format for use with Connect() and SetDataFormat(). |
static int |
TG_DATA_BLINK_STRENGTH
|
| Method Summary | |
|---|---|
static int |
Connect(int connectionId,
java.lang.String serialPortName,
int serialBaudrate,
int serialDataFormat)
Connects a ThinkGear Connection, given by connectionId, to a serial
communication (COM) port in order to communicate with a ThinkGear module. |
static void |
Disconnect(int connectionId)
Disconnects the ThinkGear Connection, given by connectionId, from
its serial communication (COM) port. |
static int |
EnableAutoRead(int connectionId, int enable)
Enables or disables background auto-reading of the connection. |
static int |
EnableBlinkDetection(int connectionId, int enable)
Enables and disables the non-embedded eye blink detection. Non-embedded blink detection is disabled by default. |
static int |
EnableLowPassFilter(int connectionId, int rawSamplingRate)
As a ThinkGear Connection reads and parses raw EEG wave values (via the TG_ReadPackets() function), the driver can automatically apply a 30Hz low pass filter to the raw wave data. |
static void |
FreeConnection(int connectionId)
Frees all memory associated with the given ThinkGear Connection. |
static int |
GetDriverVersion()
Returns a number indicating the version of the ThinkGear Communications Driver (TGCD) library accessed by this API. |
static int |
GetNewConnectionId()
Returns an ID handle (an int) to a newly-allocated ThinkGear Connection object. |
static double |
GetValue(int connectionId,
int dataType)
Returns the most recently read value of the given dataType, which
is one of the DATA_* constants defined above. |
static int |
GetValueStatus(int connectionId,
int dataType)
Returns Non-zero if the dataType was updated by the most recent call
to GetValue(). |
static int |
ReadPackets(int connectionId,
int numPackets)
Attempts to use the ThinkGear Connection, given by connectionId,
to read numPackets of data from the serial stream. |
static int |
SendByte(int connectionId,
int b)
Sends a byte through the ThinkGear Connection (presumably to a ThinkGear module). |
static int |
SetBaudrate(int connectionId,
int serialBaudrate)
Attempts to change the baud rate of the ThinkGear Connection, given by connectionId, to serialBaudrate. |
static int |
SetDataFormat(int connectionId,
int serialDataFormat)
Attempts to change the data Packet parsing format used by the ThinkGear Connection, given by connectionId, to serialDataFormat. |
static int |
SetDataLog(int connectionId,
java.lang.String filename)
As a ThinkGear Connection reads and parses Packets of data from its serial stream, it may log the parsed data into a log file. |
static int |
SetStreamLog(int connectionId,
java.lang.String filename)
As a ThinkGear Connection reads bytes from its serial stream, it may automatically log those bytes into a log file. |
static int |
WriteDataLog(int connectionId, int insertTimestamps,
java.lang.String msg)
Writes a message given by msg into the Connection's Data Log. |
static int |
WriteStreamLog(int connectionId, int insertTimestamps,
java.lang.String msg)
Writes a message given by msg into the Connection's Stream Log. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int MAX_CONNECTION_HANDLES
public static final int BAUD_1200
public static final int BAUD_2400
public static final int BAUD_4800
public static final int BAUD_9600
public static final int BAUD_57600
public static final int BAUD_115200
public static final int STREAM_PACKETS
public static final int STREAM_5VRAW
public static final int STREAM_FILE_PACKETS
public static final int DATA_BATTERY
public static final int DATA_POOR_SIGNAL
public static final int DATA_ATTENTION
public static final int DATA_MEDITATION
public static final int DATA_RAW
public static final int DATA_DELTA
public static final int DATA_THETA
public static final int DATA_ALPHA1
public static final int DATA_ALPHA2
public static final int DATA_BETA1
public static final int DATA_BETA2
public static final int DATA_GAMMA1
public static final int DATA_GAMMA2
public static final int TG_DATA_BLINK_STRENGTH
| Method Detail |
|---|
public static int GetDriverVersion()
public static int GetNewConnectionId()
public static int SetStreamLog(int connectionId,
java.lang.String filename)
filename
will turn this feature on. Calling this function with an invalid
filename, or with filename set to NULL, will turn this feature
off. This function may be called at any time for either purpose on a
ThinkGear Connection.
connectionId - The ID of the ThinkGear Connection to enable stream
logging for, as obtained from GetNewConnectionId().filename - The name of the file to use for stream logging.
Any existing contents of the file will be erased.
Set to NULL to disable stream logging by the
ThinkGear Connection.
connectionId does not refer to a valid ThinkGear
Connection ID handle.
public static int SetDataLog(int connectionId,
java.lang.String filename)
filename will turn this feature on. Calling this function
with an invalid filename, or with filename set to NULL, will turn
this feature off. This function may be called at any time for either
purpose on a ThinkGear Connection.
connectionId - The ID of the ThinkGear Connection to enable data
logging for, as obtained from GetNewConnectionId().filename - The name of the file to use for data logging.
Any existing contents of the file will be erased.
Set to NULL to disable stream logging by the
ThinkGear Connection.
connectionId does not refer to a valid ThinkGear
Connection ID handle.
public static int Connect(int connectionId,
java.lang.String serialPortName,
int serialBaudrate,
int serialDataFormat)
connectionId, to a serial
communication (COM) port in order to communicate with a ThinkGear module.
It is important to check the return value of this function before
attempting to use the Connection further for other functions in this API.
connectionId - The ID of the ThinkGear Connection to connect, as
obtained from GetNewConnectionId().serialPortName - The name of the serial communication (COM) stream
port. COM ports on PC Windows systems are named
like '\\.\COM4' (remember that backslashes in
strings in most programming languages need to be
escaped), while COM ports on Windows Mobile
systems are named like 'COM4:' (note the colon at
the end). Linux COM ports may be named like
'/dev/ttys0'. Refer to the documentation for
your particular platform to determine the
available COM port names on your system.serialBaudrate - The baudrate to use to attempt to communicate
on the serial communication port. Select from
one of the BAUD_* constants defined above,
such as BAUD_9600 or BAUD_57600.
BAUD_9600 is the typical default baud rate
for standard ThinkGear modules.serialDataFormat - The type of ThinkGear data stream. Select from
one of the STREAM_* constants defined above.
Most applications should use STREAM_PACKETS
(the data format for Embedded ThinkGear modules).
STREAM_5VRAW is supported only for legacy
non-embedded purposes.
connectionId does not refer to a valid ThinkGear
Connection ID handle.
public static int ReadPackets(int connectionId,
int numPackets)
connectionId,
to read numPackets of data from the serial stream. The Connection
will (internally) "remember" the most recent value it has seen of
each possible ThinkGear data type, so that any subsequent call to
GetValue() will return the most recently seen values.
Set numPackets to -1 to attempt to read all Packets of data that
may be currently available on the serial stream.
connectionId - The ID of the ThinkGear Connection which should
read packets from its serial communication stream,
as obtained from GetNewConnectionId().numPackets - The number of data Packets to attempt to read from
the ThinkGear Connection. Only the most recently
read value of each data type will be "remembered"
by the ThinkGear Connection. Setting this parameter
to -1 will attempt to read all currently available
Packets that are on the data stream.
connectionId does not refer to a valid ThinkGear
Connection ID handle.
public static double GetValue(int connectionId,
int dataType)
dataType, which
is one of the DATA_* constants defined above. Use ReadPackets()
to read more Packets in order to obtain updated values. Afterwards, use
GetValueStatus() to check if a call to ReadPackets() actually
updated a particular dataType.
NOTE: This function will terminate the program with a message printed
to stderr if connectionId is not a valid ThinkGear Connection, or
if dataType is not a valid DATA_* constant.
connectionId - The ID of the ThinkGear Connection to get a data
value from, as obtained from GetNewConnectionId().dataType - The type of data value desired. Select from one of
the DATA_* constants defined above. Refer to the
documentation of each constant for details of how
to interpret its value.
dataType.
public static int GetValueStatus(int connectionId,
int dataType)
dataType was updated by the most recent call
to GetValue(). Returns 0 otherwise.
connectionId - The ID of the ThinkGear Connection to get a data
value from, as obtained from GetNewConnectionId().dataType - The type of data value desired. Select from one of
the DATA_* constants defined above.
NOTE: This function will terminate the program with a message printed
to stderr if connectionId is not a valid ThinkGear Connection, or
if dataType is not a valid DATA_* constant.
dataType was updated by the most recent call
to GetValue(). Returns 0 otherwise.
public static int SendByte(int connectionId,
int b)
ReadPackets() function) at some point BEFORE
calling this function. This is to ENSURE the Connection is
communicating at the right baud rate. Sending Command Byte
at the wrong baud rate may put a ThinkGear module into an
indeterminate and inoperable state until it is reset by power
cycling (turning it off and then on again).
NOTE: After sending a Command Byte that changes a ThinkGear baud rate,
you will need to call SetBaudrate() to change the baud rate
of your connectionId as well. After such a baud rate change,
it is important to check for a valid Packet to be received by
ReadPacket() before attempting to send any other Command
Bytes, for the same reasons as describe in the WARNING above.
connectionId - The ID of the ThinkGear Connection to send a byte
through, as obtained from GetNewConnectionId().b - The byte to send through. Note that only the lowest
8-bits of the value will actually be sent through.
connectionId does not refer to a valid ThinkGear
Connection ID handle.
public static int SetBaudrate(int connectionId,
int serialBaudrate)
connectionId, to serialBaudrate. This function does not typically
need to be called, except after calling SendByte() to send a
Command Byte that changes the ThinkGear module's baud rate. See
SendByte() for details and NOTE.
connectionId - The ID of the ThinkGear Connection to send a byte
through, as obtained from GetNewConnectionId().serialBaudrate - The baudrate to use to attempt to communicate
on the serial communication port. Select from
one of the BAUD_* constants defined above,
such as BAUD_9600 or BAUD_57600.
BAUD_9600 is the typical default baud rate
for standard ThinkGear modules.
connectionId does not refer to a valid ThinkGear
Connection ID handle.
public static int SetDataFormat(int connectionId,
int serialDataFormat)
connectionId, to serialDataFormat. This
function does not typically need to be called, and is provided only
for special testing purposes.
connectionId - The ID of the ThinkGear Connection to send a byte
through, as obtained from GetNewConnectionId().serialDataFormat - The type of ThinkGear data stream. Select from
one of the STREAM_* constants defined above.
Most applications should use STREAM_PACKETS
(the data format for Embedded ThinkGear modules).
STREAM_5VRAW is supported only for legacy
non-embedded purposes.
connectionId does not refer to a valid ThinkGear
Connection ID handle.public static void Disconnect(int connectionId)
connectionId, from
its serial communication (COM) port. Note that after this call, the
Connection will not be valid to use with any of the API functions
that require a valid ThinkGear Connection, except SetStreamLog(),
SetDataLog(), Connect(), and FreeConnection().
Note that FreeConnection() will automatically disconnect a
Connection as well, so it is not necessary to call this function
unless you wish to reuse the connectionId to call Connect()
again.
connectionId - The ID of the ThinkGear Connection to disconnect, as
obtained from GetNewConnectionId().public static void FreeConnection(int connectionId)
connectionId without freeing
it first.
connectionId - The ID of the ThinkGear Connection to disconnect, as
obtained from GetNewConnectionId().public static native int EnableAutoRead(int connectionId, int enable)
enable to anything other than 0 will enable background auto-reading on the specified connection. Setting enable to 0 will disable it.
connectionId - The connection to enable/disable background auto-reading on.enable - Zero (0) to disable background auto-reading, any other value to enable.
connectionId does not refer to a valid ThinkGear
Connection ID handle.
public static native int EnableBlinkDetection(int connectionId, int enables)
connectionId - The connection to enable/disable background auto-reading on.enable - Zero (0) to disable background auto-reading, any other value to enable.
connectionId does not refer to a valid ThinkGear
Connection ID handle.
public static native int EnableLowPassFilter(int connectionId, int rawSamplingRate)
connectionId - The ID of the ThinkGear Connection to disconnect, as
obtained from GetNewConnectionId(). rawSamplingRate -Specify the sampling rate that the hardware
is currently sampling at. Set this to 0 (zero)
or any invalid rate at any time to immediately
disable the driver's automatic low pass filtering.
NOTE: Currently, the only valid raw sampling rate
is 512 (MindSet headsets). All other rates will
return -2.
connectionId does not refer to a valid ThinkGear
Connection ID handle.
rawSamplingRate is not a valid rate. Currently only a sampling rate of 512 (Hz) is valid which is the raw sampling rate of MindSet headset.
public static native int WriteDataLog(int connectionId, int insertTimestamp, java.lang.String msg)
msg into the Connection's Data Log.
Optionally the message can be written onto a new line preceded by
a timestamp. The Connection's Data Log must be already opened
by TG_SetDataLog(), otherwise this function returns an error.
connectionId - The ID of the ThinkGear Connection to disconnect, as
obtained from TG_GetNewConnectionId().
insertTimestamp - If set to any non-zero number, a newline
and timestamp are automatically prepended
to the msg in the Stream Log file. Pass
a zero for this parameter to disable the
insertion of newline and timestamp before
msg.
msg - The message to write into the Data Log
File. For Data Log parsers to ignore
the message as a human-readable comment
instead of hex bytes, prepend a '#' sign
to indicate it is a comment.
connectionId does not refer to a valid ThinkGear
Connection ID handle.
public static native int WriteStreamLog(int connectionId, int insertTimestamp, java.lang.String msg)
connectionId - The ID of the ThinkGear Connection to disconnect, as
obtained from TG_GetNewConnectionId().
insertTimestamp - If set to any non-zero number, a newline
and timestamp are automatically prepended
to the msg in the Stream Log file. Pass
a zero for this parameter to disable the
insertion of newline and timestamp before
msg.
msg - The message to write into the Data Log
File. For Data Log parsers to ignore
the message as a human-readable comment
instead of hex bytes, prepend a '#' sign
to indicate it is a comment.
connectionId does not refer to a valid ThinkGear
Connection ID handle.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||